<script setup>
import { ref } from 'vue';

const name = ref('')
const emit = defineEmits(['add'])
const add = () => {
  if (name.value) {
    emit('add', name.value)
    name.value = ''
  }
}
</script>

<template>
  <header class="header">
    <h1>todos</h1>
    <input class="new-todo" placeholder="What needs to be done?" autofocus v-model="name" @keydown.enter="add" />
  </header>
</template>

<style lang="less" scoped>

</style>
